package easymall.controller;

import easymall.po.Cart;
import easymall.pojo.MyCart;
import easymall.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class CartController {
    @Autowired
    private CartService cartService;

    @PostMapping("/findCart")
    public Cart findCart(@RequestBody Cart cart){return cartService.findCart(cart);}

    @PostMapping("/addCart")
    public int addCart(@RequestBody Cart cart){return cartService.addCart(cart);}

    @PostMapping("/updateCart")
    public int updateCart(@RequestBody Cart cart){return cartService.updateCart(cart);}

    @GetMapping("/showCart")
    public List<MyCart> showCart(@RequestParam int user_id){return cartService.showCart(user_id);}

    @PostMapping("/updateBuyNum")
    public void updateBuyNum(@RequestBody Cart cart){cartService.updateBuyNum(cart);}

    @GetMapping("/delCart")
    public void delCart(@RequestParam Integer cartID){cartService.delCart(cartID);}

    @GetMapping("/findByCartID")
    public MyCart findByCartID(@RequestParam  Integer cartID){return cartService.findByCartID(cartID);}
}
